﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics.Contracts;

namespace WpfApplication
{
    [ContractClass(typeof(PowerContract))]
    interface IPowerSignal
    {
        double Voltage { get; set; }
        double Current { get; set; }
    }

    [ContractClassFor(typeof(IPowerSignal))]
    public sealed class PowerContract : IPowerSignal
    {
        double IPowerSignal.Voltage
        {
            [Pure]
            get
            {
                return Contract.Result<double>();
            }
            set
            {
                Contract.Requires<ArgumentOutOfRangeException>((value >= 0.0) && (value <= SignalConstants.voltageMax));
            }    
        }
        double IPowerSignal.Current
        {
            [Pure]
            get
            {
                return Contract.Result<double>();
            }
            set
            {
                Contract.Requires<ArgumentOutOfRangeException>((value >= 0.0) && (value <= SignalConstants.currentMax));
            }
        }
    }
}
